package com.campus.dao.provider;

import com.campus.pojo.SysRole;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;
import java.util.Map;

public class RoleDaoDynSqlProvider {
    public String getAllRole(Map<String ,Object> params){
        String sql = new SQL(){
            {
                SELECT("*");
                FROM("sys_role");
                if (params.get("areaId") != null && !((String) params.get("areaId")).equals("")){
                    WHERE("areaId = #{areaId}");
                }
            }
        }.toString();
        if (params.get("pager") != null){
            sql += " limit #{pager.firstLimitParam},#{pager.perPageRows};";
        }
        return sql;
    }

    public String  count(Map<String ,Object> params){
        return new SQL(){
            {
                SELECT("count(*)");
                FROM("sys_role");
                if (params.get("areaId") != null && !((String) params.get("areaId")).equals("")){
                    WHERE("areaId = #{areaId}");
                }
            }
        }.toString();
    }
}
